package com.yzy.controller;

import com.yzy.dao.BookDao;
import com.yzy.dao.DoctorDao;
import com.yzy.dao.PatientDao;
import com.yzy.entity.Doctors;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

public class PatientBookServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        DoctorDao dao= new DoctorDao();
        PrintWriter out;
        //1用户信息用【list】
        List<Doctors> doctorList = dao.findAll();
        //2
        response.setContentType("text/html;charset=utf-8");
        out=response.getWriter();
        out.print("<table boder='2' align='center'>");
        out.print("<tr>");
        out.print("<td>医生编号</td>");
        out.print("<td>医生姓名</td>");
        out.print("<td>医生年龄</td>");
        out.print("<td>医生经历</td>");
        out.print("<td>医生密码</td>");
        out.print("<td>医生性别</td>");
        out.print("<td>操作</td>");
        out.print("</tr>");

        for(Doctors doctors : doctorList){
            out.print("<tr>");
            out.print("<td>"+doctors.getDid()+"</td>");
            out.print("<td>"+doctors.getDname()+"</td>");
            out.print("<td>"+doctors.getDage()+"</td>");
            out.print("<td>"+doctors.getExperience()+"</td>");
            out.print("<td>"+"******"+"</td>");
            out.print("<td>"+doctors.getDsex()+"</td>");
            out.print("<td><a href='/myWeb/patient/book/button?doctorId="+doctors.getDid()+"'>预约用户</a></td>");
            out.print("</tr>");
        }
        out.print("</table>");
    }
}
